#region File Description
//-----------------------------------------------------------------------------
// Author: JCBDigger
// URL: http://Games.DiscoverThat.co.uk
//-----------------------------------------------------------------------------
// Changes for XNA 4 taken from the example at:
//      http://msdn.microsoft.com/en-us/library/bb976065.aspx
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using AssetData;
#endregion

namespace Editor
{
    /// <summary>
    /// Custom vertex structure for drawing point sprite particles.
    /// </summary>
    public struct ParticleVertex : IVertexType
    {

        // Stores which corner of the particle quad this vertex represents.
        private Short2 vertexPosition0;

        // Stores the starting position of the particle.
        private Vector3 vertexPosition1;

        // Stores the starting velocity of the particle.
        public Vector3 vertexNormal;

        // Four random values, used to make each particle look slightly different.
        private Color vertexColor;

        // The time (in seconds) at which this particle was created.
        private float vertexTextureCoordinate;

        // Describe the layout of this vertex structure.
        public static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration
        (
            new VertexElement(0, VertexElementFormat.Short2,
                                 VertexElementUsage.Position, 0),

            new VertexElement(4, VertexElementFormat.Vector3,
                                 VertexElementUsage.Position, 1),

            new VertexElement(16, VertexElementFormat.Vector3,
                                  VertexElementUsage.Normal, 0),

            new VertexElement(28, VertexElementFormat.Color,
                                  VertexElementUsage.Color, 0),

            new VertexElement(32, VertexElementFormat.Single,
                                  VertexElementUsage.TextureCoordinate, 0)
        );

        // Describe the size of this vertex structure.
        // Not necessary for XNA 4 uses the following instead
        //      ParticleVertex.VertexDeclaration.VertexStride;
        //public const int SizeInBytes = 36;

        public ParticleVertex(Short2 corner, Vector3 pos, Vector3 vel, Color rand, float createTimeSec)
        {
            vertexPosition0 = corner;
            vertexPosition1 = pos;
            vertexNormal = vel;
            vertexColor = rand;
            vertexTextureCoordinate = createTimeSec;
        }
 
        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }

        // Stores which corner of the particle quad this vertex represents.
        public Short2 Corner
        {
            get { return vertexPosition0; }
            set { vertexPosition0 = value; }
        }

        // Stores the starting position of the particle.
        public Vector3 Position
        {
            get { return vertexPosition1; }
            set { vertexPosition1 = value; }
        }

        // Stores the starting velocity of the particle.
        public Vector3 Velocity
        {
            get { return vertexNormal; }
            set { vertexNormal = value; }
        }

        // Four random values, used to make each particle look slightly different.
        public Color Random
        {
            get { return vertexColor; }
            set { vertexColor = value; }
        }

        // The time (in seconds) at which this particle was created.
        public float Time
        {
            get { return vertexTextureCoordinate; }
            set { vertexTextureCoordinate = value; }
        }


    
    }
}
